const pool = require("../db/conn");

exports.selectAuthList = async function() {
    let sql =   " SELECT "+
                " 	rs_role.role_id,  "+
                " 	rs_role.role_name,  "+
                " 	rs_role.role_system "+
                " FROM "+
                " 	rs_role "+
                " WHERE "+
                " 	rs_role.role_system <> -1 AND rs_role.role_name <> '老师' AND rs_role.role_name <> '学生' ";
    let conn = await pool.getConnection();
    let [result] = await conn.execute(sql);
    conn.release();
    return result
}

exports.selectAllRoleRights = async function () {
    let sql =   " SELECT "+
                " 	rs_role_right.role_id,  "+
                " 	rs_right.right_api,  "+
                " 	rs_role_right.right_function "+
                " FROM "+
                " 	rs_role_right "+
                " 	LEFT JOIN "+
                " 	rs_right "+
                " 	ON  "+
                " 		rs_role_right.right_id = rs_right.right_id "+
                " ORDER BY "+
                "   rs_role_right.role_id ";
    let conn = await pool.getConnection();
    let [result] = await conn.execute(sql);
    conn.release();
    return result;
}


